//
//  UIBarButtonItem + button.swift
//  sinaWeibo
//
//  Created by apple on 16/3/2.
//  Copyright © 2016年 Qifeng Yan. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 便利构造函数
    convenience init(imageName:String) {
        let button = UIButton()
        
        button.setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal);
        button.setBackgroundImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        button.sizeToFit()
        
        self.init(customView: button)
    }
    
    
    class func categoryBarButtonItem (imageName: String) -> UIBarButtonItem {
        let button = UIButton()
        
        button.setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal);
        button.setBackgroundImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        button.sizeToFit()
        
        return UIBarButtonItem(customView: button)
    }
    

}